package cn.tedu.egnotice1.controller;

import cn.tedu.egnotice1.mapper.NoticeaAddMapper;
import cn.tedu.egnotice1.pojo.entity.Notice;
import cn.tedu.egnotice1.pojo.vo.AddParamVO;
import cn.tedu.egnotice1.pojo.vo.NoticeDetailInfoVO;
import cn.tedu.egnotice1.pojo.vo.NoticeListVO;


import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
public class NoticeController {
    @Autowired
    NoticeaAddMapper noticeMapper;
    @PostMapping("/v1/notice/add")
    @ResponseBody
    public String  NoticeAddParam(String title,Integer type,String content,Integer status){
        AddParamVO addParamVO = new AddParamVO();
        addParamVO.setTitle(title);
        addParamVO.setType(type);
        addParamVO.setContent(content);
        addParamVO.setStatus(status);
        addParamVO.setCreateTime(new Date());
        addParamVO.setUpdateTime(new Date());

        addParamVO.setUserId(1L);

        System.out.println(addParamVO);
        noticeMapper.insertNotice(addParamVO);
        return "新增咨询成功";
    }
    @GetMapping("/v1/notice/list")
    @ResponseBody
    public NoticeListVO noticeListQuery(Long id) {
        Notice notice = new Notice();
        NoticeListVO noticeListVO= noticeMapper.selectNotice(id);
        System.out.println(noticeListVO);
        return noticeListVO;
    }
    @GetMapping("/v1/notice/detail")
    @ResponseBody
    public NoticeDetailInfoVO selectDetailInfo(Long id) {
        NoticeDetailInfoVO noticeDetailInfoVO = noticeMapper.selectNOticeDetail(id);
        System.out.println(noticeDetailInfoVO);
        return noticeDetailInfoVO;
    }

}
